﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using VR_ChuangKe.Share.Map;

public class CircleDemo : MonoBehaviour {
    private int circleCount;
    public GameObject prefab;
    public BaseScrollCircle Circle;
    public void AddCircle()
    {
        BCWAction<GameObject>.GBCWObject<ScrollCircleItem> onShowAction = (p) =>
        {
            GameObject clone = Instantiate(prefab);
            clone.transform.SetParent(p.parent);
            //clone.GetComponent<RectTransform>().anchorMax = Vector2.up;
            //clone.GetComponent<RectTransform>().anchorMin = Vector2.up;
            clone.SetActive(true);
            clone.transform.GetChild(0).GetComponent<Text>().text ="序号:"+ (int)p.data[0];
            return clone;
        };
        BCWAction.VBCWAction<ScrollCircleItem> onHideAction = (p) =>
        {
            if (p.IsHasShow())
            {
                Destroy(p.rt.gameObject);
            }
        };
        BCWAction.VBCWAction<ScrollCircleItem> onDisposetion = (p) =>
        {
            if (p.IsHasShow())
            {
                Destroy(p.rt.gameObject);
            }
            p.data = null;
        };
        BCWAction.VBCWAction<string, object[], ScrollCircleItem> onSendMessage = (v1, v2, v3) =>
        {
           
        };
        BCWAction.VBCWAction<ScrollCircleItem> onUpdatePosAction = (v2) =>
        {
            v2.rt.localPosition = v2.GetPos();
        };
        BCWAction<Vector2>.GBCWObject<ScrollCircleItem> onSizeAction = (p) => { return new Vector2(787, 50); };
        ScrollCircleItem item = new ScrollCircleItem(onShowAction,onHideAction,onDisposetion,onSendMessage,onUpdatePosAction,onSizeAction);
        circleCount++;
        item.data = new object[] { circleCount };
        item.parent = Circle.scrollview.content;
        Circle.AddCircleItem(item,true);
    }
	
}
